#@adminLayout() #define main()
<body class="gray-bg">
	<div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="dept-form">
					<div class="select-list">
						<ul>
							<li>
								产权：
								<select name="c_pro" id="c_pro" onchange="changeInfo()">
			               		  #for(data: getOrgInfo(c_pro))
			               		 	<option value="#(data.ccode)">#(data.cname)</option>
			               		  #end
                     		 </select>
							</li>
							
							<li>
								部门名称：<input type="text" name="cname"/>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.treeTable.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
                
            <div class="btn-group-sm" id="toolbar" role="group">
		        <!-- <a class="btn btn-success" onclick="$.operate.add('0')" >
                    <i class="fa fa-plus"></i> 新增
                </a> -->
                <!-- <a class="btn btn-primary" onclick="$.operate.edit()" >
		            <i class="fa fa-edit"></i> 修改
		        </a> -->
                <a class="btn btn-info" id="expandAllBtn">
                    <i class="fa fa-exchange"></i> 展开/折叠
                </a>
	        </div>
       		 <div class="col-sm-12 select-table table-striped">
	            <table id="bootstrap-tree-table"></table>
	        </div>
	    </div>
	</div>
	
	<script type="text/javascript">
		var prefix = "#(ctx)/sysorg";
		
		$(function() {
		    var options = {
		        code: "ccode",
		        parentCode: "pcode",
		        uniqueId: "ccode",
		        url: prefix + "/list",
		        removeUrl: prefix + "/remove?ccode={id}",
		        modalName: "部门",
		        columns: [{
                    field: 'selectItem', 
                    radio: true
                 },
                 {
		            field: 'cname',
		            title: '部门名称',
		            align: "left",
		            formatter: function(value, row, index) {
		                if (row.pcode == '0') {
		                    return '<span style="color:red">【顶级】</span> '+value;
		                } else {
		                    return value;
		                }
		            }
		        },
		        {
		            field: 'isort',
		            title: '排序',
		            align: "left"
		        },
		        {
		            title: '操作',
		            align: 'left',
		            formatter: function(value, row, index) {
		                
	                    var actions = [];
	                    actions.push('<a class="btn btn-success btn-xs"  href="javascript:void(0)" onclick="edit(\'' + row.ccode + '\',\''+row.ilayer+'\',\''+row.c_pro+'\')"><i class="fa fa-edit"></i>编辑</a> ');
	                    actions.push('<a class="btn btn-info  btn-xs"  href="javascript:void(0)" onclick="add(\'' + row.ccode + '\',\'' + row.pcode + '\',\''+row.ilayer+'\',\''+row.c_pro+'\')"><i class="fa fa-plus"></i>新增</a> ');
	                    
	                    actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.ccode + '\',\''+row.c_pro+'\')"><i class="fa fa-trash"></i>删除</a>');
	                    return actions.join('');
		                
		            }
		        }]
		    };
		    $.treeTable.init(options);
		});
		
		function add(ccode,pcode,ilayer,c_pro)
		{
			var url = prefix + "/edit?pcode="+ccode+"&ilayer="+ilayer+"&c_pro="+c_pro;
			$.modal.open("新增部门", url);
		}
		
		function edit(ccode,ilayer,c_pro)
		{
			var url = prefix + "/edit?ccode="+ccode+"&c_pro="+c_pro;
			$.modal.open("编辑部门", url);
		}
		
		function changeInfo()
		{
			$.treeTable.search()
		}
	</script>
</body>
#end